﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;

namespace PaintDotNetForms
{
    public partial class FrmLang : Form
    {
        internal class LangItem
        {
            public string LangCode;
            public string Name;

            public override string ToString()
            {
                return Name;
            }
        }

        public string SelectedLangCode
        {
            get
            {
                return (cbxLangs.SelectedItem as LangItem).LangCode.Clone() as string;
            }
        }       


        public FrmLang()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(new ConfigManager().Config.Lang);
            InitializeComponent();
            cbxLangs.Items.Add(new LangItem() { Name = "Polish", LangCode = "pl" });
            cbxLangs.Items.Add(new LangItem() { Name = "English", LangCode = "en" });
            int idx = 0;
            foreach(LangItem li in cbxLangs.Items)
            {
                if (li.LangCode == new ConfigManager().Config.Lang)
                {
                    cbxLangs.SelectedIndex = idx;
                    break;
                }
                idx++;
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            
            DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
